package code._16reflect._07add;

import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;

//自定义类加载
public class MyClassLoaderTest {
    public static void main(String[] args) throws ClassNotFoundException, NoSuchMethodException, InstantiationException, IllegalAccessException, InvocationTargetException {
        //定义加载路径
        String classPath="";
        //创建类加载器对象
        MyClassLoader myClassLoader = new MyClassLoader(classPath);
        Class<?> logCls = myClassLoader.loadClass("");
        ClassLoader classLoader = logCls.getClassLoader();
        System.out.println("classLoader = " + classLoader);

        //获取要执行的方法对象
        Method method = logCls.getDeclaredMethod("func");
        Object o = logCls.newInstance();
        method.invoke(o);
    }
}
